/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "Image.h"
#include "Renderer.h"

namespace liba
{
namespace lib2d
{
namespace hard
{
namespace soft
{

Image::Image( Renderer * renderer, int sx, int sy )
:	renderer( renderer ),
	width( sx ),
	height( sy )
{
	canvas = Array2D<ColorPacked>( sx, sy );
}

void Image::blit( const Vector2 & src, const Rect & rect, int alpha )
{
	renderer->blit( this, src, rect, alpha );
}

void Image::blit( const Vector2 & src, int alpha )
{
	renderer->blit( this, src, Rect( 0, 0, width, height ), alpha );
}

void Image::fill_rect( const Rect & dst_rect, int alpha )
{
	renderer->fill_image( this, dst_rect, Rect( 0, 0, width, height ), alpha );
}

void Image::fill_rect( const Rect & dst_rect, const Rect & src_rect, int alpha )
{
	renderer->fill_image( this, dst_rect, src_rect, alpha );
}

void * Image::lock( int * stride )
{
	*stride = canvas.cx() * 4;
	return canvas.begin();
}

} //namespace soft
} //namespace hard
} //namespace lib2d
} //namespace liba

